package com.ruoyi.od_organizer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.od_organizer.domain.Od_organizer_Activity;
import com.ruoyi.od_organizer.service.IOd_organizer_ActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动发布Controller
 * 
 * @author 榛子
 * @date 2023-07-29
 */
@RestController
@RequestMapping("/od_organizer/activity_organizer")
public class Od_organizer_ActivityController extends BaseController
{
    @Autowired
    private IOd_organizer_ActivityService od_organizer_ActivityService;

    /**
     * 查询活动发布列表
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:activity_organizer:list')")
    @GetMapping("/list")
    public TableDataInfo list(Od_organizer_Activity od_organizer_Activity)
    {
        startPage();
        List<Od_organizer_Activity> list = od_organizer_ActivityService.selectOd_organizer_ActivityList(od_organizer_Activity);
        return getDataTable(list);
    }

    /**
     * 导出活动发布列表
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:activity_organizer:export')")
    @Log(title = "活动发布", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Od_organizer_Activity od_organizer_Activity)
    {
        List<Od_organizer_Activity> list = od_organizer_ActivityService.selectOd_organizer_ActivityList(od_organizer_Activity);
        ExcelUtil<Od_organizer_Activity> util = new ExcelUtil<Od_organizer_Activity>(Od_organizer_Activity.class);
        util.exportExcel(response, list, "活动发布数据");
    }

    /**
     * 获取活动发布详细信息
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:activity_organizer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(od_organizer_ActivityService.selectOd_organizer_ActivityById(id));
    }

    /**
     * 新增活动发布
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:activity_organizer:add')")
    @Log(title = "活动发布", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Od_organizer_Activity od_organizer_Activity)
    {
        return toAjax(od_organizer_ActivityService.insertOd_organizer_Activity(od_organizer_Activity));
    }

    /**
     * 修改活动发布
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:activity_organizer:edit')")
    @Log(title = "活动发布", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Od_organizer_Activity od_organizer_Activity)
    {
        return toAjax(od_organizer_ActivityService.updateOd_organizer_Activity(od_organizer_Activity));
    }

    /**
     * 删除活动发布
     */
    @PreAuthorize("@ss.hasPermi('od_organizer:activity_organizer:remove')")
    @Log(title = "活动发布", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(od_organizer_ActivityService.deleteOd_organizer_ActivityByIds(ids));
    }
}
